@@ -1,3 +1,14 @@
+Tue 11 Jan 2010 23:07:00 GMT - Release 0.88
+ Fix documentation for overriding Serialize and Deserialize actions
+ in Catalyst::Controller::REST.
+
+ Avoid warning with empty response bodies and new Catalyst version
+ (>= 5.80030)
+
+ Returning a body of '' is now possible - Catalyst::Action::Serialize
+ acts like Catalyst::Action::RenderView (>= 0.16) by using the has_body
+ predicate in Catalyst::Response (>= 5.80030)
+
Wed 3 Nov 2010 19:46:00 GMT - Release 0.87
Fix Request class role when used with new Moose and other request
@@ -19,7 +19,7 @@ no_index:
- t
- xt
requires:
- Catalyst::Runtime: 5.80
+ Catalyst::Runtime: 5.80030
Class::Inspector: 1.13
Config::General: 0
Data::Serializer: 0.36
@@ -41,4 +41,4 @@ requires:
resources:
license: http://dev.perl.org/licenses/
repository: git://git.shadowcat.co.uk/catagits/Catalyst-Action-REST.git
-version: 0.87
+version: 0.88
@@ -11,7 +11,7 @@ all_from 'lib/Catalyst/Action/REST.pm';
requires 'Moose' => '1.03';
requires 'namespace::autoclean';
-requires('Catalyst::Runtime' => '5.80');
+requires('Catalyst::Runtime' => '5.80030');
requires('Params::Validate' => '0.76');
requires('YAML::Syck' => '0.67');
requires('Module::Pluggable::Object' => undef);
@@ -38,7 +38,7 @@ feature 'JSON (application/json) support',
author_requires 'JSON' => '2.12';
author_requires 'JSON::XS' => '2.2222';
-feature 'Data::Taxi (text/x-data-taxi) support',
+feature 'Data::Taxi (text/x-data-taxi) support (deprecated)',
-default => 0,
'Data::Taxi' => undef;
@@ -55,9 +55,10 @@ SEE ALSO
a sensible set of defaults for a controller doing REST.
This class automatically adds the Catalyst::TraitFor::Request::REST role
- to your request class. If you're writing a webapp which provides RESTful
- responses and still needs to accommodate web browsers, you may prefer to
- use Catalyst::TraitFor::Request::REST::ForBrowsers instead.
+ to your request class. If you're writing a web application which
+ provides RESTful responses and still needs to accommodate web browsers,
+ you may prefer to use Catalyst::TraitFor::Request::REST::ForBrowsers
+ instead.
Catalyst::Action::Serialize, Catalyst::Action::Deserialize
@@ -9,7 +9,7 @@ use Safe;
my $compartment = Safe->new;
$compartment->permit_only( qw(padany null lineseq const pushmark list anonhash anonlist refgen leaveeval undef) );
-our $VERSION = '0.87';
+our $VERSION = '0.88';
$VERSION = eval $VERSION;
sub execute {
@@ -6,7 +6,7 @@ use namespace::autoclean;
extends 'Catalyst::Action';
use JSON;
-our $VERSION = '0.87';
+our $VERSION = '0.88';
$VERSION = eval $VERSION;
sub execute {
@@ -5,7 +5,7 @@ use namespace::autoclean;
extends 'Catalyst::Action';
-our $VERSION = '0.87';
+our $VERSION = '0.88';
$VERSION = eval $VERSION;
sub execute {
@@ -5,7 +5,7 @@ use namespace::autoclean;
extends 'Catalyst::Action';
-our $VERSION = '0.87';
+our $VERSION = '0.88';
$VERSION = eval $VERSION;
sub execute {
@@ -6,7 +6,7 @@ use namespace::autoclean;
extends 'Catalyst::Action';
use YAML::Syck;
-our $VERSION = '0.87';
+our $VERSION = '0.88';
$VERSION = eval $VERSION;
sub execute {
@@ -7,7 +7,7 @@ extends 'Catalyst::Action::SerializeBase';
use Module::Pluggable::Object;
use MRO::Compat;
-our $VERSION = '0.87';
+our $VERSION = '0.88';
$VERSION = eval $VERSION;
has plugins => ( is => 'rw' );
@@ -10,7 +10,7 @@ use Catalyst::Controller::REST;
BEGIN { require 5.008001; }
-our $VERSION = '0.87';
+our $VERSION = '0.88';
$VERSION = eval $VERSION;
sub new {
@@ -161,7 +161,7 @@ You likely want to look at L<Catalyst::Controller::REST>, which implements a
sensible set of defaults for a controller doing REST.
This class automatically adds the L<Catalyst::TraitFor::Request::REST> role to
-your request class. If you're writing a webapp which provides RESTful
+your request class. If you're writing a web application which provides RESTful
responses and still needs to accommodate web browsers, you may prefer to use
L<Catalyst::TraitFor::Request::REST::ForBrowsers> instead.
@@ -6,7 +6,7 @@ use namespace::autoclean;
extends 'Catalyst::Action';
use Data::Serializer;
-our $VERSION = '0.87';
+our $VERSION = '0.88';
$VERSION = eval $VERSION;
sub execute {
@@ -6,7 +6,7 @@ use namespace::autoclean;
extends 'Catalyst::Action::Serialize::JSON';
use JSON::XS ();
-our $VERSION = '0.87';
+our $VERSION = '0.88';
$VERSION = eval $VERSION;
sub _build_encoder {
@@ -6,7 +6,7 @@ use namespace::autoclean;
extends 'Catalyst::Action';
use JSON ();
-our $VERSION = '0.87';
+our $VERSION = '0.88';
$VERSION = eval $VERSION;
has encoder => (
@@ -4,7 +4,7 @@ use namespace::autoclean;
extends 'Catalyst::Action::Serialize::JSON';
-our $VERSION = '0.87';
+our $VERSION = '0.88';
$VERSION = eval $VERSION;
after 'execute' => sub {
@@ -4,7 +4,7 @@ use namespace::autoclean;
extends 'Catalyst::Action';
-our $VERSION = '0.87';
+our $VERSION = '0.88';
$VERSION = eval $VERSION;
sub execute {
@@ -5,7 +5,7 @@ use namespace::autoclean;
extends 'Catalyst::Action';
-our $VERSION = '0.87';
+our $VERSION = '0.88';
$VERSION = eval $VERSION;
sub execute {
@@ -7,7 +7,7 @@ extends 'Catalyst::Action';
use YAML::Syck;
use URI::Find;
-our $VERSION = '0.87';
+our $VERSION = '0.88';
$VERSION = eval $VERSION;
sub execute {
@@ -6,7 +6,7 @@ use namespace::autoclean;
extends 'Catalyst::Action';
use YAML::Syck;
-our $VERSION = '0.87';
+our $VERSION = '0.88';
$VERSION = eval $VERSION;
sub execute {
@@ -7,7 +7,7 @@ extends 'Catalyst::Action::SerializeBase';
use Module::Pluggable::Object;
use MRO::Compat;
-our $VERSION = '0.87';
+our $VERSION = '0.88';
$VERSION = eval $VERSION;
has _encoders => (
@@ -23,7 +23,7 @@ sub execute {
$self->maybe::next::method(@_);
return 1 if $c->req->method eq 'HEAD';
- return 1 if length( $c->response->body );
+ return 1 if $c->response->has_body;
return 1 if scalar @{ $c->error };
return 1 if $c->response->status =~ /^(?:204)$/;
@@ -8,7 +8,7 @@ use Module::Pluggable::Object;
use Catalyst::Request::REST;
use Catalyst::Utils ();
-our $VERSION = '0.87';
+our $VERSION = '0.88';
$VERSION = eval $VERSION;
after BUILDARGS => sub {
@@ -2,7 +2,7 @@ package Catalyst::Controller::REST;
use Moose;
use namespace::autoclean;
-our $VERSION = '0.87';
+our $VERSION = '0.88';
$VERSION = eval $VERSION;
=head1 NAME
@@ -565,28 +565,33 @@ L<Catalyst::Action::Serialize>.
The C<begin> method uses L<Catalyst::Action::Deserialize>. The C<end>
method uses L<Catalyst::Action::Serialize>. If you want to override
either behavior, simply implement your own C<begin> and C<end> actions
-and use MRO::Compat:
+and forward to another action with the Serialize and/or Deserialize
+action classes:
package Foo::Controller::Monkey;
use Moose;
use namespace::autoclean;
-
+
BEGIN { extends 'Catalyst::Controller::REST' }
- sub begin :Private {
+ sub begin : Private {
my ($self, $c) = @_;
... do things before Deserializing ...
- $self->maybe::next::method($c);
+ $c->forward('deserialize');
... do things after Deserializing ...
}
+ sub deserialize : ActionClass('Deserialize') {}
+
sub end :Private {
my ($self, $c) = @_;
... do things before Serializing ...
- $self->maybe::next::method($c);
+ $c->forward('serialize');
... do things after Serializing ...
}
+ sub serialize : ActionClass('Serialize') {}
+
=back
=head1 A MILD WARNING
@@ -3,7 +3,7 @@ use Moose;
use namespace::autoclean;
-our $VERSION = '0.87';
+our $VERSION = '0.88';
$VERSION = eval $VERSION;
extends 'Catalyst::Request::REST';
@@ -7,7 +7,7 @@ use namespace::autoclean;
extends 'Catalyst::Request';
with 'Catalyst::TraitFor::Request::REST';
-our $VERSION = '0.87';
+our $VERSION = '0.88';
$VERSION = eval $VERSION;
# Please don't take this as a recommended way to do things.
@@ -4,7 +4,7 @@ use namespace::autoclean;
with 'Catalyst::TraitFor::Request::REST';
-our $VERSION = '0.87';
+our $VERSION = '0.88';
$VERSION = eval $VERSION;
has _determined_real_method => (
@@ -3,7 +3,7 @@ use Moose::Role;
use HTTP::Headers::Util qw(split_header_words);
use namespace::autoclean;
-our $VERSION = '0.87';
+our $VERSION = '0.88';
$VERSION = eval $VERSION;
has [qw/ data accept_only /] => ( is => 'rw' );
@@ -1,6 +1,6 @@
use strict;
use warnings;
-use Test::More tests => 9;
+use Test::More 0.88;
use Data::Serializer;
use FindBin;
@@ -35,4 +35,17 @@ $res2 = request($t->get(url => '/serialize/test_second'));
ok( $res2->is_success, 'request succeeded (deprecated config)' );
is( $res2->content, "{'lou' => 'is my cat'}", "request returned proper data");
-1;
+$res = request($t->get(url => '/serialize/empty_serialized'));
+is $res->content, q[{'foo' => 'bar'}], 'normal case ok';
+ok $res->header('Content-Length'), 'set content-length when we serialize';
+
+$res = request($t->get(url => '/serialize/empty_not_serialized_undef'));
+is $res->content, '', "body explicitly set to undef results in '' content";
+ok !$res->header('Content-Length'), "body explicitly set to undef - no automatic content-length";
+
+$res = request($t->get(url => '/serialize/empty_not_serialized_blank'));
+is $res->content, '', "body explicitly set to '' results in '' content";
+ok !$res->header('Content-Length'), "body explicitly set to '' - no automatic content-length";
+
+done_testing;
+
@@ -32,4 +32,26 @@ sub test_second :Local :ActionClass('Serialize') {
};
}
+# For testing saying 'here is an explicitly empty body, do not serialize'
+sub empty : Chained('/') PathPart('serialize') CaptureArgs(0) {
+ my ($self, $c) = @_;
+ $c->stash( rest => { foo => 'bar' } );
+}
+
+# Normal case
+sub empty_serialized :Chained('empty') Args(0) ActionClass('Serialize') {
+}
+
+# Undef body
+sub empty_not_serialized_undef :Chained('empty') Args(0) ActionClass('Serialize') {
+ my ($self, $c) = @_;
+ $c->res->body(undef);
+}
+
+# Blank body
+sub empty_not_serialized_blank :Chained('empty') Args(0) ActionClass('Serialize') {
+ my ($self, $c) = @_;
+ $c->res->body('');
+}
+
1;
@@ -17,6 +17,7 @@ __PACKAGE__->config(
},
);
__PACKAGE__->setup;
-__PACKAGE__->log( Test::Catalyst::Log->new );
+__PACKAGE__->log( Test::Catalyst::Log->new )
+ unless __PACKAGE__->debug;
1;
@@ -23,6 +23,8 @@ local $ENV{LC_ALL} = 'C';
all_pod_files_spelling_ok();
__DATA__
+Wiki
+json
APIs
ActionClass
Daisuke
@@ -38,6 +40,7 @@ Maki
Maki
Marchex
Pearcey
+Rolsky
RESTful
RESTful
SERIALIZERS